home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
029a
/
fdate44.zip
/
FDATE.DOC
< prev
next >
Wrap
Text File
|
1992-01-21
|
48KB
|
1,222 lines
FDATE Version 4.4a Jan 20, 1992
===================================================================
FDATE: a utility for date manipulation in batch files.
===================================================================
Stephen Ferg 5113 N. 8th Road, Arlington, VA 22205-1201
Voice (703) 525-2241 CompuServe 73377,1157
=======================================================================
Format:
FDATE /Ffunc /Adate /Bdate /Iformat /Oformat
/Nnum /Ddayofweek /Pstring /Sstring
=======================================================================
FDATE PARAMETERS
================
The parameters that are required depend on the function requested.
Parameters that are specified, but not needed, are ignored.
Executing FDATE without any parameters displays a brief help screen.
Parameters can be in any order and upper or lower case.
Note that although format specifications are not case sensitive,
they ARE "text sensitive". If any characters are missing,
added, or mistyped, the format specification will be rejected.
(A common mistake is to enter "/format" instead of "/Fformat".
This mistake can be avoided by using the /Ff function alias.)
/F requests a particular FDATE function
If this parameter is not specified, or is specified incorrectly,
FDATE displays a help screen. If you unexpectedly get the help
screen displayed, you probably have omitted the /F parameter.
/N number of days (always a number)
/A date A (for date functions)
/B date B (for date functions)
If the /A parameter is omitted, /Atoday is assumed.
If the /B parameter is omitted, /Btoday is assumed.
/A number A (for math functions)
/B number B (for math functions)
/I specifies format of input date(s)
If the /I parameter is omitted, /Imm-dd-ccyy is assumed.
/O specifies format of output date
If the /O parameter is omitted, /Od1 is assumed.
/L specifies language of output.
/Leng English-language output
/Lfr French-language output
If the /L parameter is omitted, /Leng [English] is assumed.
/P specifies a prefix string for the output
/S specifies a suffix string for the output
Maximum length for a prefix or suffix string is 80 bytes.
These optional parameters may always be specified or omitted.
They must be enclosed in single quotes, double quotes, or
square brackets
Note that "whitespace" will be removed from these strings,
so formatting of /P and /S strings cannot be controlled using
spaces. To format strings, use periods or ASCII 255 (hex'ff')
as filler.
EXAMPLES
FDATE /Ff /At /Od1 /P"Today is "
FDATE /Fdif /At /B12-25-TTTT /S" days until Christmas"
FDATE /Fdif /At /B12-25-TTTT /P"It is " /S" days 'til Xmas"
FDATE /Ff /A05-08-TTTT /S[ -- "Buffalo Bill's" birthday]
ERROR HANDLING
==============
If FDATE detects an error:
(1) it will return an errorlevel of 1 (rather than 0), and
(2) its output will be 3 lines:
* the word ERROR
* a DOS batch-file ECHO statement that displays an error message
* a DOS batch-file PAUSE statement
If Fdate output is displayed directly, or redirected to NUL:
you can detect an error by testing the errorlevel for a value of 1.
If Fdate output is piped to an environment manipulation utility such
as STRINGS or GET, the environment variable will be set to ERROR.
Errorlevel will be set by STRINGS/GET, and will probably be 0.
In such a case, the only way to detect an error is to test the
environment variable for the value ERROR.
If FDATE output is redirected to a batch file, which is then
CALLed to set an environment variable, the batch file will:
* set the environment variable to ERROR,
* ECHO the error message, and
* pause.
You can detect an error by testing errorlevel for the value 1
either before or after you CALL the batch file.
You can detect an error by testing the environment variable for the
value ERROR, AFTER you have CALLed the batch file.
----------------------------------------------------------------------
EXAMPLE:
rem use FDATE to check validity of year in parm %1
Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy /P"Received year parm: "
if errorlevel 1 echo Year parm [%1] is not valid.
if errorlevel 1 goto endit
EXAMPLE:
rem use FDATE to verify %1, and GET to put it into %year%
Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy | GET ZE /V%year% >nul
if (%year%)==(ERROR) echo Year parm [%1] is not valid.
if (%year%)==(ERROR) goto endit
EXAMPLE:
rem use FDATE to verify %1, call a batch file to put it into %year%
Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy /P"@set year=">junktemp.bat
call junktemp.bat
del junktemp.bat
if errorlevel 1 echo Year parm [%1] is not valid.
if errorlevel 1 goto endit
SYMBOL CONVENTIONS
==================
The following symbols are used in specifying date formats:
SYMBOL EXAMPLE MEANING
------ ------- -------------------------------------
cc 19 century
yy 93 year
mm 02 month
zm 2 month without leading zero
dd 08 day
zd 8 day without leading zero
mn February month name
mn3 Feb month name, first 3 characters only
dow Tuesday day of week
dow3 Tue day of week, first 3 characters only
dow# 3 day of week as a number (Sunday=1, Monday = 2, etc.)
today is a "pseudodate" representing the current date
t is an alias for the "today" pseudodate
hh:mm 09:05 hours and minutes
hhmm 0905 hours and minutes
ss 09 seconds
PSEUDODATES
===========
t (or today)
can be used with either /A or /B, e.g. /Atoday or /At.
EXAMPLE
rem Get the date that is 90 days from today
FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
FDATE /Fadd /N90 /At /Omm-dd-ccyy
rem determine if this year is a leapyear
FDATE /Ff /At /OLY
tt when used in place of a 2-digit DD string, will cause
Fdate to use today's day-of-the-month.
Example: FDATE /Ff /Imm-dd-ccyy /A01-tt-1992 /Od1
tt when used in place of a 2-digit MM string, will cause
Fdate to use today's month.
Example: FDATE /Ff /Imm-dd-ccyy /Att-01-1992 /Od1
tt when used in place of a 2-digit YY string, will cause
Fdate to use today's year (CCYY).
Example: FDATE /Ff /Imm-dd-yy /A01-01-tt /Od1
Note that TT can NOT be used for only the YY part of a CCYY
input year. The following, for example, is NOT valid:
Example: FDATE /Ff /Imm-dd-ccyy /A01-01-19tt /Od1
tttt when used in place of a 4-digit CCYY string, will cause
Fdate to use today's year (CCYY).
Example: FDATE /Ff /Imm-dd-ccyy /A01-01-tttt /Od1
EXAMPLES:
Show the first Monday in the second quarter of this year
FDATE /Fw /Iccyymmdd /Atttt0301 /D2 /N1 /Od1 /P"First Monday in QTR#2: "
Show the last Friday on/before the 15th of this month.
FDATE /Fw /Iccyymmdd /Atttttt15 /D6 /N-1 /Od1 /P"Friday before the 15th: "
INPUT FORMATS
=============
FORMAT EXAMPLES DISCUSSION
------ --------- -----------------------------
ccyymmdd 19922002
mm-dd-ccyy 02-20-1992 In an input format specification, the dash
02/20/1992 symbols represent ANY non-numeric symbol.
2/20/1992 Leading zeros need not be present.
mm-dd-yy 02-20-92 In this input format,
02/20/92 cc=19 is assumed if YY is greater than 20
02/20/92 otherwise, cc=20 is assumed
NOTE
If ALL input dates are specified using the "today" pseudodate, (i.e.
/At, /Bt) then it is not necessary to supply an input format using /I.
OUTPUT FORMATS
==============
FORMAT EXAMPLES DISCUSSION
------ --------- -----------------------------
dd-mn3-yy 08-Feb-92 CompuServe-style date
ccyy 1993
ccyymm 199302 useful for triggering monthly processing
ccyymmdd 19930208 useful for putting current date in filename
yymmdd 908208 useful for putting current date in filename
mmdd 0208
dd 08
zd 8
In the following formats, months precede days (American style)
------------------------------------------------------------------
mm/dd/ccyy 02/08/1993
mm-dd-ccyy 02-08-1993
mm.dd.ccyy 02.08.1993 British-style dates
zm/zd/ccyy 2/8/1993 no leading zeros in day or month
zm-zd-ccyy 2-8-1993 no leading zeros in day or month
zm.zd.ccyy 2.8.1993 British-style dates
mm/dd/yy 02/08/92
mm-dd-yy 02-08-92
mm.dd.yy 02.08.92 British-style dates
zm/zd/yy 2/8/92 no leading zeros in day or month
zm-zd-yy 2-8-92 no leading zeros in day or month
zm.zd.yy 2.8.92 no leading zeros in day or month
In the following formats, days precede months (European style)
------------------------------------------------------------------
dd/mm/ccyy 02/08/1993
dd-mm-ccyy 02-08-1993
dd.mm.ccyy 02.08.1993 British-style dates
zd/zm/ccyy 2/8/1993 no leading zeros in day or month
zd-zm-ccyy 2-8-1993 no leading zeros in day or month
zd.zm.ccyy 2.8.1993 British-style dates
dd/mm/yy 02/08/92
dd-mm-yy 02-08-92
dd.mm.yy 02.08.92 British-style dates
zd/zm/yy 2/8/92 no leading zeros in day or month
zd-zm-yy 2-8-92 no leading zeros in day or month
zd.zm.yy 2.8.92 British-style dates
------------------------------------------------------------------
Day-of-the-week output formats
------------------------------------------------------------------
dow# 5 Sunday=1, Monday=2 .... Saturday=7.
dow Thursday name of day of week
Jeudi if /Lfr specified
dow3 Thu first 3 characters of name of day of week
Jeu if /Lfr specified
------------------------------------------------------------------
LY 0 1 if year is a leapyear, otherwise 0.
------------------------------------
365 + this number gives total
number of days in the year.
28 + this number gives total
number of days in February.
------------------------------------
d1 Saturday, February 5, 1992
le Samedi 5 Fevrier 1992 [/Lfr specified]
t1 9:05 pm
HH:MM 09:05 ("Military time") (9:05 am)
21:05 (9:05 pm)
HHMM 0905 ("Military time") (9:05 am)
2105 (9:05 pm)
HH:MM:SS 21:05:30
HHMMSS 210530
full 9:05 pm on Saturday, February 5, 1992
9:05 pm le Samedi 5 Fevrier 1992 [/Lfr specified]
-----------------------------------------------------------------------
NOTE that the following formats contain embedded spaces. Consequently
they must be enclosed in double quotes. EXAMPLE: /O"mn zd, ccyy".
-----------------------------------------------------------------------
"zd mn ccyy" 5 February 1992
"zd mn, ccyy" 5 February, 1992
"mn3 dd ccyy" Feb 05 1992
"mn3 dd, ccyy" Feb 05, 1992
"mn zd, ccyy" February 5, 1992
"JULIAN" OUTPUT FORMATS
=======================
FORMAT EXAMPLES DISCUSSION
------ --------- -----------------------------
julian 311 BUSINESS "Julian date" expressed as number
of days since January 1 of the same year.
day# 727198 TRUE "Julian date" expressed as number
of days since January 1, 0001.
minute# 33088 "Julian minutes": time expressed as number
of minutes since midnight, January 1, 1990.
second# 633088 "Julian seconds": time expressed as number
of seconds since midnight, January 1, 1990.
----------------------------------------------------------------------
Running FDATE with /O parameter for a "Julian time" produces a
number based on the current time of day and the date in the /A parm.
If, on January 10, 1992 at 2 pm, you run FDATE this way:
FDATE /Ff /Atoday /Ominute#
it will produce the Julian minute for January 10, 1992 at 2 pm.
If, on January 10, 1992 at 2 pm, you run FDATE this way:
FDATE /Ff /A01-15-1992 /Imm-dd-ccyy /Ominute#
it will produce the Julian minute for January 15, 1992 at 2 pm.
----------------------------------------------------------------------
DATE FUNCTIONS
==============
FUNCTION FDATE /Ffunc /Adate /Iformat /Oformat
-------- -------------------------------------------
format this is a synonym for function "f"
f returns /Adate in format specified by /Oformat
Since /Aformat and /Oformat can be different, the FORMAT
function is used to change a date from one format to another.
Because of the wide variety of output formats, the FORMAT
function can also be used to determine the day of week of the
date, whether the date is in a normal or leap year, etc.
EXAMPLES
FDATE /Ff /A19920101 /Iccyymmdd /O"mn zd, ccyy"
FDATE /Ff /Atoday /Od1
FDATE /Fformat /Atoday /Od1
FUNCTION FDATE /Ffunc /Nnumdays /Adate /Iformat /Oformat
-------- -------------------------------------------
add Adds /Ndays to /Adate, produces date in /Oformat format
sub Subtracts /Ndays from /Adate, produces date in /Oformat format
EXAMPLES
FDATE /Fadd /N90 /A01-01-1992 /Imm-dd-ccyy /Od1
FDATE /Fsub /N90 /A01-01-1992 /Imm-dd-ccyy /Od1
FDATE /Fadd /N90 /Atoday /Od1
FUNCTION FDATE /Ffunc /Adate /Bdate /Iformat
-------- -------------------------------------------
comp compares the dates specified on the /A and /B parms.
returns when
LT /A is less than (earlier than) /B
EQ /A is equal to (same as) /B
GT /A is greater than (later than) /B
dif Returns number of days between /Adate and /Bdate
Order of the two dates is not significant.
Note that for DIF, both dates must be in the SAME
format, the input format specified in /Iformat.
If the two dates are not in the same format, reformat one
of the dates using the /Ff function and
a utility like STRINGS or GET.
EXAMPLES
FDATE /Fdif /A01-01-1992 /B11-11-1992 /Imm-dd-ccyy
FDATE /Fdif /A11-11-1992 /B01-01-1992 /Imm-dd-ccyy
FDATE /Fdif /Atoday /B01-01-1992 /Imm-dd-ccyy
FUNCTION FDATE /Ffunc /Adate /Iformat /Oformat /Ddow# /Ndow-count
-------- -------------------------------------------
w W (weekday) function.
This function accepts a date specification in parm /A and
returns the date of the /Nth /Day-of-the-week
before or after /Adate. For example:
If /A specifies November 14, 1992
/D specifies the number for Thursday (i.e., 5)
/N specifies a week count of 3
then /Fw returns the date of the third Thursday after
November 14, 1992. (See full example, below)
Note that /N may be negative. If, in the above example, /N
is specified as -3, then Fdate returns the date of the third
Thursday BEFORE November 14, 1992.
If the date specified on the /A parms falls on the same day
of the week as was specified on the /D parm, then that will
be considered to be the first date meeting that day-of-week
criterion. That is, If November 14, 1992 fell on a
Thursday, and if /N was 1 or -1, then the output date would
be the same as the input date, i.e. November 14, 1992.
The acceptable values for /N (number of weeks) is in
the range of 99..-99. A value of zero (i.e. /N0) is invalid.
EXAMPLES
find date of Thanksgiving (4th Thursday in November) in 1992
FDATE /Fw /A11-01-1992 /Imm-dd-ccyy /D5 /N4 /Od1
returns: Thursday November 26, 1992
find the beginning of the work-week (Monday, 2nd day of week)
AFTER Thanksgiving, 1992
FDATE /Fw /A11-26-1992 /Imm-dd-ccyy /D2 /N1 /Od1
find the beginning of the work-week (Monday, 2nd day of week)
BEFORE Thanksgiving, 1992
FDATE /Fw /A11-26-1992 /Imm-dd-ccyy /D2 /N-1 /Od1
MATH FUNCTIONS
==============
FUNCTION FDATE /Ffunc /Anum /Bnum
-------- -------------------------------------------
#add returns the sum of the integers specified
on the /A and /B parms. Can be used to calculate the
"Julian" minute(second, date) in the future from a given
"Julian" minute(second, date).
#sub (not supported)
no numeric subtraction operation (as such) is supported.
Often, you will find that #dif will do what you want.
#dif is the same as subtraction in which the smaller
number is subtracted from the larger number; it will never
return a negative number. If you really MUST have
subtraction, which might return a negative result, you can
add two numbers, one of which is a negative number.
For example, to subtract 3 from 2:
FDATE /F#add /A2 /B-3 [ returns: -1 ]
#dif returns the difference between the integers specified
on the /A and /B parms. Can be used to calculate the
number of minutes(seconds, days) between two
"Julian" minutes(seconds, dates).
#comp compares the integers specified on the /A and /B parms.
returns when
LT /A is less than /B
EQ /A is equal to /B
GT /A is greater than /B
PUTTING FDATE OUTPUT INTO AN ENVIRONMENT VARIABLE
=================================================
FDATE's output is written to standard output, that is, it is displayed
on the screen. Output can be redirected to a file, or it can piped to
a utility (such as STRINGS or GET) that will put it into an
environment variable.
Manipulating the environment is an incredibly tricky business. There
are questions of the local versus master environment, the version of
DOS you are running, and the environment under which you are running
(DOS, Windows, Carousel). In order to keep FDATE focussed on
date-related issues, I have not attempted to make it put its output
directly into an environment variable.
One way to put FDATE's output into an environment variable is to use
the /P (prefix string) feature to create a DOS "SET" statement,
redirect the output to a batch file, and CALL the batch file.
Since CALL first appeared in DOS 3.3, you will need DOS 3.3 or
greater to use this technique.
FDATE /Ff /Atoday /O"mn zd, ccyy" /P"@SET FDATE=" >JUNKTEMP.BAT
call JUNKTEMP.BAT
del JUNKTEMP.BAT
There are also shareware and public domain utilities that are written
specifically to manipulate environment variables, and do that job very
well. FDATE's output can be put into an environment variable by piping
it to one of these utilities. When piping FDATE output to a utility,
you can prevent the output from being ECHOed to the screen by
redirecting the output to NUL.
EXAMPLE: use STRINGS to put date into DATE1 environment variable
FDATE /Ff /At /Od1 | STRINGS date1= ASK >NUL
-----------------------------------------------------------------
I recommend Bob Stephan's GET and PC Magazine's STRINGS.
As of December 30, 1991, the current version of GET is GET25.ZIP.
On CompuServe, use IBMFF to look for GET*.ZIP in CIS:IBMSYS
GET is also available from the Public Software Library in Houston.
On CompuServe, look for STRING.ZIP in Utilities Lib of ZNT:UTILFORUM
-----------------------------------------------------------------
=======================================================================
EXAMPLE #1
Redirect FDATE output to a file, or to a callable batch file,
or pipe it to STRINGS or GET to store it in an environment variable
=======================================================================
rem display Fdate output on screen
FDATE /Ff /At /Od1 /P"Today is "
rem Redirect FDATE output to a file
FDATE /Ff /At /Od1 /P"Today is " >FDATE.OUT
rem Redirect FDATE output to a callable batch file
FDATE /Ff /Atoday /O"mn zd, ccyy" /P"@SET DATE1=" >JUNKTEMP.BAT
call JUNKTEMP.BAT
del JUNKTEMP.BAT
rem Pipe FDATE output to STRINGS to store it in DATE1 environment var
FDATE /Ff /Atoday /O"mn zd, ccyy" |STRINGS date1= ASK >NUL
rem Pipe FDATE output to GET to store it in DATE1 environment var
FDATE /Ff /Atoday /O"mn zd, ccyy" |GET ZE /Vdate1 >NUL
=======================================================================
EXAMPLE #2
Find the difference (in days) between two dates in different formats
Use GET to put FDATE output into environment variables.
=======================================================================
set date1=05-10-1992
rem reformat date literal into same format as date1
FDATE /Ff /Imm-dd-yy /A05-08-92 /Omm-dd-ccyy | GET ZE /Vdate2>NUL
rem get difference between date1 and date2
FDATE /Fdif /Imm-dd-ccyy /A%date1% /B%date2%| GET ZE /vdiff>NUL
echo The difference is %diff% days.
=======================================================================
EXAMPLE #3
Schedule a program to run at a specified time in the future. Note that
this involves a lot of disk activity because DOS re-reads the batch
file from disk every time it does a GOTO LOOPTOP. If you do this, it
is a good idea to run the batch file from a RAM DISK.
=======================================================================
REM GET CURRENT JULIAN MINUTE AND PUT IN ENVIRONMENT VARIABLE RUNTIME
FDATE /Ff /At /Ominute# |STRINGS RunTime= ASK >NUL
REM ADD 120 MINUTES (2 HOURS) TO ENVIRONMENT VARIABLE RUNTIME
FDATE /F#add /A%RunTime% /B120 |STRINGS RunTime= ASK >NUL
REM LOOP UNTIL NOWTIME HAS REACHED RUNTIME
:LoopTop
FDATE /Ff /At /Ominute# |STRINGS NowTime= ASK >NUL
FDATE /F#comp /A%NowTime% /B%RunTime% |STRINGS TimeComp= ASK >NUL
if (%TimeComp%)==(LT) goto loopTOP
:LoopEnd
echo STARTING EXECUTION OF APPLICATION: [program name]
=======================================================================
EXAMPLE #4
Rename file BACKUP.LOG to a name that contains today's date
=======================================================================
FDATE /Ff /Atoday /Oyymmdd /P"@SET DATE1=" >JUNKTEMP.BAT
call JUNKTEMP.BAT
del JUNKTEMP.BAT
ren BACKUP.LOG BK%DATE1%.LOG
SET DATE1=
=======================================================================
EXAMPLE #4b
Use FDATE to rename a log file to a name that will be unique within a
minute time-frame. This is a way to keep an historical record of a
series of log files. Since the file will retain its original date/time
stamp, you will still be able easily to tell when it was created.
In this example, we use GET to put the FDATE output into
environment variable TEMPVAR.
=======================================================================
FDATE /FF /At /Ominute# | GET ZE /Vtempvar >nul
REN online.log %tempvar%.log
SET tempvar=
=======================================================================
EXAMPLE #5
Find the calendar date corresponding to Julian date 1992:200
by adding 200 to the last day of the previous year.
=======================================================================
FDATE /Fadd /A12-31-1991 /Imm-dd-ccyy /N200 /Od1
=======================================================================
EXAMPLE #6
Check to see if parameter %1 is a valid year (CCYY)
=======================================================================
@echo off
rem determine if value sent in through parameter %1 is a valid year
Fdate /Ff /Imm-dd-ccyy /A01-01-%1 /Od1 >nul
if errorlevel 1 echo Parm 1 was not a valid year: %1
if errorlevel 1 goto endit
echo PUT YOUR BATCH PROCESSING HERE, USING YEAR VALUE OF: %1
:endit
=======================================================================
EXAMPLE #7
Find the 4th Thursday in November (Thanksgiving)
=======================================================================
Fdate /Fw /D5 /N4 /A11-01-%year% /Imm-dd-ccyy /Od1 /P"Thanksgiving: "
=======================================================================
EXAMPLE #8
Show the number of the anniversary for some special event.
=======================================================================
SEE HOLIDAYS.BAT
=======================================================================
EXAMPLE #9
Run a program once a day, when you boot for the first time that day.
=======================================================================
@echo off
cls
REM -------------------------------------------------------------------
REM Run daily processing once a day. Put this code in AUTOEXEC.BAT.
REM This batch file requires DOS 3.3+, since it uses CALL.
REM -------------------------------------------------------------------
if not exist LastRun.BAT goto RunNow
REM LastRun.Bat will set env var LASTRUN to date AUTOEXEC was last run.
call LastRun.BAT
REM Compare today's date to date in LASTRUN
Fdate /Fcomp /Imm-dd-ccyy /At /B%LastRun% /P"@set COMP=">junktemp.BAT
call junktemp.BAT
del junktemp.BAT
IF (%COMP%)==(EQ) goto NoRun
REM if user reset system clock, today's date may be less than LASTRUN
IF (%COMP%)==(LT) goto NoRun
rem Daily processing hasn't been run today. Run it.
echo RUNNING ONCE A DAY PROCESSING: Job 1
echo RUNNING ONCE A DAY PROCESSING: Job 2
echo RUNNING ONCE A DAY PROCESSING: ............. etc.
rem ------------------------------------------------------------------
rem Save today's date in a new version of LastRun.BAT
rem Note that this will be executed only if daily processing runs to
rem completion without hanging the machine or aborting the batch file.
rem ------------------------------------------------------------------
Fdate /Ff /Omm-dd-ccyy /At /P"@set LastRun=">LastRun.BAT
:NoRun
set LastRun=
set COMP=
FDATE'S ALGORITHMS
==================
FDATE IS DESIGNED FOR BUSINESS, NOT HISTORICAL, APPLICATIONS
============================================================
FDATE is intended for business applications, not historical ones.
As far as FDATE is concerned, the calendar has followed the same
pattern, unchanged, since January 1, 0001.
-------------------------------------------------------------------
FDATE does not take into account historical changes in the calendar
such as the glitch in English dates that occurred when Britain
moved from the Julian to Gregorian calendar in the 18th century,
or Russia made the same move in the early 20th century.
-------------------------------------------------------------------
FDATE'S BASE DATE
=================
Internally, date manipulations are based on translating a calendar
date into an "absolute" or "TRUE Julian" date: a date expressed
as the number of days from some day in the distant past.
FDATE's base date is January 1, 0001 (i.e. day 1 of month 1 of year 1)
FDATE's absolute date for January 1, 0001 is 1.
FDATE's absolute date for January 1, 1992 is 727198.
FDATE'S LEAP YEAR ALGORITHM
===========================
Every year evenly divisible by 4 IS a leap year
EXCEPT THAT
Every year evenly divisible by 100 IS NOT a leap year
EXCEPT THAT
Every year evenly divisible by 400 IS a leap year
.
Using this algorithm
1983 is not a leap year
1984 is a leap year
1900 is not a leap year
2000 is a leap year
See "A Machine Algorithm for Processing Calendar Dates", by
Henry F. Fliegel (Georgetown University Observatory) and
Thomas C. Van Flandern (U.S. Naval Observatory)
COMMUNICATIONS OF THE ACM, Volume 11, Number 10, October 1968
There is supposedly a new adjustment to the leapyear algorithm,
which specifies the additional exception:
EXCEPT THAT
Every year evenly divisible by 4000 IS a leap year
See "Bit By Bit" column, COMPUTER LANGUAGE, November 1989, p. 148.
This adjustment is not part of FDATE's leapyear algorithm.
Unless your application is working with dates 2,000 years in the
future, the lack of this exception will be irrelevant for you.
DEMONSTRATION BATCH FILES
=========================
FDATE ships with a number of demonstration batch files. These are
sample applications that illustrate some of the ways that FDATE
might be used to build applications. They can be studied for
ideas for ways of using FDATE. They can also be used "as is", or
copied and customized to build applications that meet your own
special needs.
DEMONSTRATION BATCH FILE: HOLIDAYS.BAT
======================================
HOLIDAYS without any parameters displays events in current year.
HOLIDAYS with a year parameter displays events in that year.
EXAMPLE: HOLIDAYS displays events in current year
EXAMPLE: HOLIDAYS 1999 displays events in year 1999.
As the holidays are displayed, you can dump each screen display
to a printer by pressing SHIFT+PRINTSCREEN.
DEMONSTRATION BATCH FILE: ALARM
===============================
ALARM.BAT is like a simple alarm clock for your PC. ALARM.BAT waits
until a specified time, then triggers an alarm: it beeps and displays a
message. It continues until someone presses CONTROL-BREAK.
If you enter just "ALARM" at the DOS prompt, without any parameters,
ALARM displays a HELP screen that shows how to use it.
ALARM uses ANSI control codes to control screen color and cursor
placement, so it requires ANSI.SYS in order to work properly.
If you are not using ANSI.SYS, it will display some garbage
characters on your screen unless you modify the batch file to remove
the ANSI control codes.
USAGE : ALARM shows current time in hhmm format
USAGE : ALARM hhmm [msg] waits until hhmm, then sounds an alarm
EXAMPLE : ALARM 0930 [sounds alarm at 9:30 am]
EXAMPLE : ALARM 930 Staff meeting [sounds alarm at 9:30 am]
EXAMPLE : ALARM 1800 [sounds alarm at 6:00 pm]
For midnight, specify 0000 or 2400 for hhmm.
EXAMPLE : ALARM 2400 START MIDNIGHT BATCH RUN
The first thing that ALARM.BAT does is to change to the M: drive. M:
is presumed to be a RAM disk. Before you can use ALARM.BAT, you
should use your favorite text editor to change the RAM disk designation
to point to your own RAM disk. It is possible to run ALARM.BAT from a
normal hard disk or floppy, but because ALARM.BAT does a LOT of disk
activity, it is strongly recommended that you make your current
directory a RAM disk before running it.
To prevent repeated disk accesses to find the FDATE program, you
should also have FDATE on the RAM disk, or be using a cache.
USING ALARM TO CREATE RUN-IT
============================
You can copy ALARM.BAT to another batch file (say, RUN-IT.BAT) and
modify it so that rather than sounding an alarm it triggers other
activiites instead: runs a program or programs, or chains to another
batch file, for example.
To create a generalized RUN-IT.BAT, you could use the words of the
message to pass in the name of a batch file that you want to be run at
a certain time, along with its parameters. Make the triggered activity
this:
rem Note that earlier SHIFT has moved batch file name to parm 1.
rem run %1 batch file.
%1 %2 %3 %4 %5 %6 %7 %8 %9
Then entering this at the DOS prompt:
RUN-IT 0001 BACKUP.BAT C: D: E:
would cause RUN-IT to wait until 1 minute past midnight, then
run a batch file called BACKUP.BAT to backup drives C:, D:, and E:.
DEMONSTRATION BATCH FILE: TIC.BAT
=================================
TIC.BAT is a sample application that uses FDATE to create a "tickler
file" batch file. The default name for the file is C:\TICKLER.BAT.
In order to use TIC on a regular basis, you should:
* Use your favorite text editor to modify TIC.BAT so that it
will use your favorite text editor in the EDIT function.
(TIC.BAT ships with the editor set to SPFPC).
* If you wish, use your favorite text editor to modify the
first few lines of TIC.BAT, so the "SET TicBAT=" statement
sets TicBAT to a different file name for the tickler batch file.
Note that you must specify the full filename,
including path and extension.
* Put TIC.BAT in a directory that is in your PATH.
* add the following lines to your AUTOEXEC.BAT file:
CLS
rem show today's appointments
call TIC T
echo.
rem show tomorrow's appointments [note space betwee T and +1]
call TIC T +1
echo.
pause
This will cause the tickler batch file to be run when you
boot your computer, showing you your scheduled appointments.
HELP
====
Running TIC without any parms will cause it to display a HELP screen.
EXAMPLE: tic
ADDING A NEW TICKLE (SINGLE DATES)
==================================
To add a new SINGLE DATE tickle, invoke TIC. The first parm must be the
date of the desired tickle, in the format mm/dd/yy. (You may use the
pseudodate TT for the current month or year, if you wish.)
This parm must be followed by a description of the appointment.
* If no description is entered, TIC interprets the date in parm 1
as a request to display the tickles for that date.
NOTE: DOS batch files strip commas out of their input parameters, so
any commas in your description will be lost.
EXAMPLE: tic 5/5/92 Cinco de Mayo party w/ Susan: El Charro @ 6pm
EXAMPLE: tic 5/5/tt Cinco de Mayo party w/ Susan: El Charro @ 6pm
ADDING A NEW TICKLE (REGULAR WEEKLY APPOINTMENTS)
=================================================
To add a new REGULAR APPOINTMENT tickle, invoke TIC. The first two
parms must be the string "dow" (or "DOW") and the day-of-the-week
number of the day of the week (e.g. 2 for Monday).
These parms should be followed by a description of the appointment.
EXAMPLE: tic dow 2 Regular Monday morning staff meeting @ 8:30 am
EXAMPLE: TIC DOW 6 STANDING TENNIS DATE WITH JANICE AT 6:30
CHECKING YOUR TICKLES
=====================
You can check your tickler file appointments for a particular day at
any time by invoking TIC with only a date parm or the pseudodate T or
TODAY.
EXAMPLE: tic t displays appointments for today
EXAMPLE: tic today displays appointments for today
EXAMPLE: tic 5/5/92 displays appointments for May 5, 1992
EXAMPLE: tic 5/5/tt displays appointments for May 5 of this year
EXAMPLE: tic tt/5/tt displays appointments for the 5th of this month
You can check your tickler file appointments for a date from one to
seven days in the future by invoking TIC with two parms: T (for today)
followed by a number of +1 through +7. Unsigned numbers are treated
as if they have a plus sign. Negative numbers will show appointments
for days in the past.
EXAMPLE: tic t displays appointments for today
EXAMPLE: tic t 1 displays appointments for tomorrow
EXAMPLE: tic t +1 displays appointments for tomorrow
EXAMPLE: tic t +7 displays appointments for a week from today
EXAMPLE: tic t -1 displays appointments for yesterday
Note that the space between the first parm "T" and the second, number
parm, is required:
EXAMPLE: tic t+2 does not recognise "t+2" as "t +2".
Displays appointments for TODAY.
If the tickler batch file does not exist, nothing will be displayed.
REMOVING DEAD TICKLES
=====================
After a while the tickler batch file will become very long, filled with
"dead tickles". You can edit it with a text editor to remove the dead
tickles:
EXAMPLE: tic edit
EXAMPLE: TIC ED
or simply delete it and let TIC create a new one the next time
you use TIC to add a tickle.
USE AND DISTRIBUTION OF FDATE
=============================
FDATE is freeware, or what is known as "zero-cost shareware".
FDATE is not what is technically called "public domain" software
because the author retains the copyright. FDATE can, however,
be copied, used, and distributed freely as long as both FDATE.EXE
and its associated doc file (FDATE.DOC) and its demonstration batch
files (FDATEX.BAT, HOLIDAYS.BAT, TIC.BAT, ALARM.BAT) are not altered
and are distributed together.
FDATE can be included in shareware packages as long as both FDATE and
its related files are included in the shareware package.
If you have received FDATE as part of some larger shareware package,
please be aware that you may freely use, copy, and distribute FDATE
without paying a fee for, or registering, the larger package.
The author explicitly disavows any claim whatsoever about the
correctness or functionality of FDATE, its documentation, and its
demonstration batch files, and disclaims liability for anything and
everything bad that might happen in connection with, before, during, or
after using it. I have tried to make FDATE work right, but everybody
makes mistakes, so you use FDATE at your own risk.
I don't know if people will find FDATE useful, and I'd like to find
out. If you find FDATE useful and use it on a regular basis, I'd
appreciate it if you would drop me a short note via US mail or
CompuServe, telling me about how you are using FDATE.
If you need other input/output formats, or if you need a different
leapyear algorithm, please contact the author.
UPDATES AND CURRENT VERSION OF FDATE
====================================
You will always be able to find the most recent version of FDATE on
CompuServe. The filename will be FDATE.ZIP, and it will be available in
one of the libraries in the CIS:IBMSYS forum and one of the libraries in
the ZNT:UTILFORUM forum. You can find it by using cross-library
searching, looking for the filename FDATE.ZIP or the keyword FDATE.
Feel free to post copies of FDATE.ZIP on any BBS that you wish, but
please do not upload it to any CompuServe library. As long as I am the
only one putting copies of FDATE onto CompuServe, we can keep confusion
over versions to a minimum.
The current distribution package (FDATE.ZIP) contains the following:
FDATE.EXE [the FDATE program]
FDATE.DOC [this file, documentation for FDATE]
FDATEX.BAT [demonstration batch files]
HOLIDAYS.BAT
TIC.BAT
FDATE REVISION HISTORY
======================
Letters appended to version numbers indicate modifications to
the doc files, without any modification to the FDATE.EXE software.
Asterisks (*) indicate most important changes in the new version.
1.1 Oct 01, 1991
First version of FDATE
1.2 Oct 15, 1991
Replaced shareware date routines with Ferg routines
NOTE THAT THERE IS NOT MUCH ERROR-CHECKING IN THIS VERSION.
1.2d Oct 16, 1991
Minor changes to show redirection and piping of FDATE output
Revised discussion of how FDATE may be distributed.
Added note on business-related, non-historical purpose of FDATE
Added note on 4000-year leap-year exception
1.2e Oct 17, 1991
Added note on why FDATE doesn't directly set an Env variable
2.0a Nov 05, 1991
Modified Help display to show parameters and their meanings
Added output format YYMMDD
Added output format minute# and second#
Added function #dif
Added test of GET and STRINGS to FDATEX.BAT
Added test of minute# and second# to FDATEX.BAT
2.1a Nov 06, 1991
Added /P parameter and modified documentation accordingly
Added JULDATE output format
Minor changes and reformatting to documenation
2.2a Nov 08, 1991
Added example showing how to put current date in a filename
Added MMDD output formats
2.3a Nov 09, 1991
Added /L (language parameter) to allow French-language output
Added the following output formats
full
"mn3 zd, ccyy"
"zd mn, ccyy"
"zd mn ccyy"
European-style date formats
in which day occurs before month (e.g. dd/mm/ccyy)
2.4a Nov 10, 1991
Fixed display of time in /Ofull so that a minutes value of
less than 10 would display with a leading zero:
e.g. "10:08 am" instead of "10:8 am".
2.5a Nov 13, 1991
Added output format CCYYMM
2.6a Nov 25, 1991
Added function "F" (/Ff) as an synonym for /Fformat
Split FDATEX.BAT off from FDATE.DOC into its own file
2.6b Dec 02, 1991
Modified this doc file to reflect new /Ff feature
2.7a Dec 07, 1991
Added CompuServe-style output format: dd-mn3-yy.
Example: 07-Dec-91
2.8a Dec 08, 1991
Added output format d1. Example: Saturday December 7, 1991
Added output format t1. Example: 9:05 am
Added "t" alias for "today" pseudodate.
Corrected FDATE "help" display which had incorrectly shown
dd-mn3-yy as an input (rather than an output) format.
Modified documentation and FDATEX.BAT to reflect software changes.
Extensively re-wrote and re-arranged FDATEX.BAT to make it
more user-friendly.
In documentation:
corrected the formats for European dates, which had incorrectly
been shown as having the same format as American dates.
2.8b Dec 09, 1991
In documentation:
Added example showing how to use fdate to create a
time-stamped filename.
2.9a Dec 26, 1991
Added STRINGS and GET info to HELP screen.
In documentation:
Added example: how to find calendar date of Julian date
3.0a Dec 27, 1991
* =============== MAJOR BUG FIX ==============================
* Fixed bug in TRUEDATE date arithmetic routine that caused
* incorrect dates to be returned for the last 2 or 3 days of
* some months.
* ============================================================
Added output formats ccyy, hh:mm, and hh:mm:ss.
Replaced output format JULDATE with JULIAN
JULDATE retained for compatibility, but not documented.
Modified this doc file and FDATEX.BAT accordingly.
3.1a Dec 28, 1991
Fixed bug: error messages were ignoring the /P parm
added HOLIDAYS.BAT to distribution package
Replaced output format LEAPYR with LY
LEAPYR retained for compatibility, but not documented.
Added new feature: when an error is detected:
output string is "ERROR", and
errorlevel is set to 1.
Changed assumed century on input formats that require only YY.
Now, if year is LT/EQ 20, a century of 20 is assumed.
FDATE will now be able to function nicely until year 2020.
Modified this doc file and FDATEX.BAT accordingly.
3.2a Dec 29, 1991
Added COMP (date compare) function
Added RUN-ONCE-A-DAY example, which uses new COMP function
Added error-trapping for dates before year 1 and after year 9999.
Fixed minor error in HELP screen (dif does NOT require /O).
Modified this doc file and FDATEX.BAT accordingly.
3.2b Dec 30, 1991
Fixed two bugs in this doc file. (Thanks to Luther Schliesser
for the bug report.) My phone number was wrong, and the
values returned by the leapyear function (0,1) were reversed.
Fixed my phone number in the HELP screen.
Minor changes in the examples in this DOC file.
3.2c Dec 31, 1991
Fixed bug in HOLIDAYS.BAT that showed New Year's Eve when
it should have showed New Year's Day.
(Thanks to Luther Schliesser for ANOTHER bug report.)
Modified HOLIDAYS.BAT to show Easter-related holidays 1992-2000
Modified HOLIDAYS.BAT to give an example of calculating
anniversaries for a user-specified "special date" (SD)
4.1a Jan 03, 1992
* Added ability to accept TT, TT, and TTTT
as pseudodates for current MM, DD, and CCYY.
* Added function: W (i.e. /Fw)
Modified this doc file, FDATEX.BAT, and HOLIDAYS.BAT accordingly.
Modified HOLIDAYS.BAT to use new /Fw to show Thanksgiving.
Added Luther Schliesser's anniversary code to HOLIDAYS.BAT
Added note on elimination of multiple spaces from /P strings.
Added note showing how to use #add and negative number to do
true subtraction.
Added note: UPDATES AND CURRENT VERSION OF FDATE
4.2a Jan 04, 1992
In FDATE.EXE:
Minor change to improve readability of an error message
In FDATE.DOC:
* expanded discussion of how to check for errors using FDATE
added documentation for TIC.BAT
In HOLIDAYS.BAT:
added Easter days for 1991 and 2001, Epiphany, Pentecost, etc.
fixed bug in algorithm for Ash Wednesday (thanks to L. Schliesser)
changed "Memorial Day" , May 30
to "Memorial Day (observed)" , the last Monday in May
inspired by L.S.'s tickler for Sharon's birthday, added "tickler"
for 500th anniversary of Columbus' discovery of America
Added TIC.BAT to FDATE distribution ZIP file
Started practice of highlighting important changes with "*"
4.2b Jan 06, 1992
In HOLIDAYS.BAT:
Corrected algorithm for Advent (thanks to L. Schliesser)
Advent is the 4 Sundays BEFORE, but NOT including, Christmas.
(The error would not make any difference before 1994)
4.2c Jan 07, 1992
In HOLIDAYS.BAT:
Added LABOR DAY (thanks to L.S.)
In TIC.BAT
* Added ability to add regular day-of-week appointments
* Added EDIT function to make it easy to edit TICKLER.BAT
Removed 18-word limit on appointment descriptions
Added ANSI.SYS codes to make help screen show in color
4.3a Jan 12, 1992
* Added defaults for: /Adate, /Bdate, /I and /O
defaults are: /Atoday, /Btoday, /Imm-dd-ccyy , /Od1
* Added British-style output format, e.g. 1.15.1992 (Jan 15, 1992)
* Added output formats: dd, zd, hhmm, hhmmss
Added ability to process +1..+5 to TIC.BAT
added ALARM.BAT to FDATE distribution package
4.4a Jan 20, 1992
* Added /S, suffix string parameter
modified CMDLIN unit to handle empty parms (e.g. /A ) better
Added Black History Month to HOLIDAYS.BAT to demonstrate /S